class ListNode:
    def __init__(self, val=0, next=None):
        self.val = val
        self.next = next


class DoubleListNode:
    def __init__(self, val=None, prev=None, next=None, child=None):
        self.val = val
        self.prev = prev
        self.next = next
        self.child = child


class LinkedListTool:
    def __new__(cls, list):
        if not list:
            return None
        head = ListNode(val=list[0])
        cur = head
        for i in range(1, len(list)):
            cur.next = ListNode(val=list[i])
            cur = cur.next
        return head


class DoubleLinkedListTool:
    def __new__(cls, list):
        head = DoubleListNode(val=list[0])
        cur = head
        for i in range(1, len(list)):
            cur.next = DoubleListNode(val=list[i], prev=cur)
            cur = cur.next
        return head


class Link:
    @staticmethod
    def each(head):
        cur = head
        while cur:
            print(cur.val,end=' ')
            cur = cur.next




